import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import * as moment from 'moment';
import { WorkOrderServiceProxy, SearchInput} from '../../../shared/service-proxies/service-proxies';

@Component({
  selector: 'app-scada',
  templateUrl: './scada.page.html',
  styleUrls: ['./scada.page.scss'],
})
export class ScadaPage implements OnInit {

  dataParam: SearchInput = new SearchInput();
  endTime: any = new Date();//Sat Jul 20 2013 10:43:36 GMT+0800 (中国标准时间)
  beginTime: any = new Date(this.endTime - 365 * 24 * 60 * 60 * 1000);
  list: any;

  constructor(
    private router: Router,
    private _WorkOrderServiceProxy: WorkOrderServiceProxy
  ) { }

  ngOnInit() {
    this.getData();
  }

  goBack() {
    this.router.navigateByUrl('home')
  }

  getData(){
    console.log("开始时间", this.beginTime);
    this.dataParam.beginDate = moment(this.beginTime);
    this.dataParam.endDate = moment(this.endTime);
    this.dataParam.result = 5;
    this._WorkOrderServiceProxy.searchScadaRepair(this.dataParam)
    .subscribe((res) =>{
      console.log(res);
      this.list = res;
    })
  }

  goTetail(data){
    console.log(data);
    this.router.navigate(['scada-detail', data]);
  }

}
